<template>
	<view>
		<view class="container">
<<<<<<< HEAD
			<view class="countdown" @tap='stopCall'>
=======
			<view @click='stopCall'>
				<back></back>
			</view>
			<view class="count">
				<text>{{count}}</text>
			</view>
			<view class="countdown" @click="stop()">
				<view class="circle"> </view>
				<view class="circle1"> </view>
				<view class="circle2"> </view>
				<view class="circle3"></view>
>>>>>>> b0cc8c0 (hello)
			</view>

			<view class="callText">
				<text>呼叫中...</text>
			</view>
<<<<<<< HEAD
			<view class="callMsg" v-for="(items,index) in callMsg" :key="index">
				<view class="callIcon">
				</view>
				<view class="callName">
					{{items.name}}
				</view>
				<view class="callPhone">
					{{items.phone}}
				</view>
			</view>
=======
			<view class="msg">
				<view class="callMsg" v-for="(items,index) in callMsg" :key="index">
					<view class="callIcon">
					</view>
					<view class="callName">
						{{items.name}}
					</view>
					<view class="callPhone">
						{{items.phone}}
					</view>
				</view>
			</view>

>>>>>>> b0cc8c0 (hello)
		</view>
	</view>
</template>

<script>
<<<<<<< HEAD
	
	import vm from'../../utils/events'
	export default {
		data() {
			return {
				showSos: true,
				showIndex: false,
				title:'',
=======
	import vm from '../../utils/events'
	export default {
		data() {
			return {
				title: '',
				count: 0,
				timer:null,
>>>>>>> b0cc8c0 (hello)
				callMsg: [{
						name: '张强',
						phone: '15012916690'
					},
					{
						name: '张强',
						phone: '15012916690'
					},
					{
						name: '张强',
						phone: '15012916690'
					}
				]

			};
		},
<<<<<<< HEAD
		onLoad(){
			this.postTitle();
		},
		props: {
			showSos: Boolean,
			showIndex: Boolean,
			required: true
		},
		methods: {
			stopCall() {
				console.log('呼叫停止');
				uni.$showMsg('呼叫停止');
				this.postTitle();
				this.changeModel();
=======
		props: ['showSos'],
		watch: {
			showSos: {
				handler(newValue, oldValue) {
					console.log(newValue);
					if (newValue == true) {
						let self = this;
						var time = 120;
						this.timer = setInterval(fun, 1000);
						function fun() {
							time--;
							if (time >= 0) {
								self.count = time + "s";
							} else if (time < 0) {

								// console.log('报警')
							}
						}
					}
				}
			}
		},
		methods: {
			stop(){	
				clearInterval(this.timer);
				timer = setInterval(fun, 1000);
				
			},
			stopCall() {
				console.log('呼叫停止');
				uni.$showMsg('呼叫停止');
				console.log("1111",this.timer);
				clearInterval(this.timer);
				// this.postTitle();				
				this.changeModel();
				// 
>>>>>>> b0cc8c0 (hello)
			},
			changeModel() {
				// this.showSos = false;
				// this.showIndex = true;
				let data = {
					showSos: false,
					showIndex: true,
<<<<<<< HEAD
					title:''
				}
				this.$emit('closeMain', data);
			},
		
		
		//子组件传参
		
		postTitle(){
			vm.$emit("customEvent", this.title);
			console.log('传输')
		}
	},
=======
					title: ''
				}
				this.$emit('closeMain', data);
			},
			//紧急呼叫
			Sos() {
				// //获取紧急呼叫号码
				// this.$request.get('/Sos/EmergencyCall', {}).then(data => {
				// 	console.log('data', data);
				// 	if (data.data.code == "200") {
				// 		let phone = data.data.phone;
				// 		// 导入Activity、Intent类
				// 		var Intent = plus.android.importClass("android.content.Intent");
				// 		var Uri = plus.android.importClass("android.net.Uri");
				// 		// 获取主Activity对象的实例  
				// 		var main = plus.android.runtimeMainActivity();
				// 		// 创建Intent  
				// 		var uri = Uri.parse("tel:" + this, phone); //电话号码  
				// 		var call = new Intent("android.intent.action.CALL", uri);
				// 		// 调用startActivity方法拨打电话  
				// 		main.startActivity(call);
				// 		console.log('呼叫成功');

				// 		//计时
				// 		let self = this
				// 		// self.show = true;
				// 		var time = 0;
				// 		var timer = setInterval(fun, 1000);

				// 		function fun() {
				// 			time++;
				// 			if (time <= 120) {
				// 				self.count = time + "s";
				// 			} else if (time >120) {								
				// 				console.log('报警')								
				// 			}
				// 		}

				// 		//发送短信
				// 		this.$request.get('/Sos/MessageForHelp', {

				// 		}).then(data => {
				// 			console.log('data', data);
				// 		})
				// 	}

				// })
			}
			//子组件传参

			// postTitle() {
			// 	vm.$emit("customEvent", this.title);
			// 	console.log('传输')
			// }
		},
>>>>>>> b0cc8c0 (hello)
	}
</script>

<style>
	.container {
		width: 90%;
		height: 80vh;
		background-color: #007AFF;
		position: relative;
		top: -8vh;
		margin: 0 auto;
		background-color: #ffffff;
		/* border: 1rpx solid #000000; */
		border: 1px solid #bfbfbf;
		box-shadow: 0 0 10px 2px #bdcee0;
		border-radius: 3vw;
		/* display: flex; */
	}

<<<<<<< HEAD
	.countdown {
		display: flex;
		width: 400rpx;
		height: 400rpx;
		background-color: #007AFF;
		margin: 2vh auto;
		text-align: center;
		border-radius: 50%;
		
		

	}

	

=======
	.count {
		width: 100px;
		height: 100px;
		background: #FD6E6E;
		color: #FFFFFF;
		text-align: center;
		top: 16vh;
		left: 33vw;
		line-height: 100px;
		font-size: 64rpx;
		border-radius: 50%;
		position: absolute;
		z-index: 999;
	}

	.time {
		font-size: 42rpx;
	}

	/* 	.countdown {
		width: 180rpx;
		height: 180rpx;
		margin: 2vh auto;
		text-align: center;
		position: relative;
		border-radius: 50%;

	} */

	.countdown {
		width: 300px;
		height: 300px;
		position: absolute;
		top: 3vh;
		left: 0;
		right: 0;
		margin: 0 auto;
	}

	@-webkit-keyframes opac {
		from {
			opacity: 1;
			width: 0;
			height: 0;
			top: 50%;
			left: 50%;
		}

		to {
			opacity: 0;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
		}
	}

	.countdown * {
		background: #FD6E6E;
		position: absolute;
		border-radius: 50%;
		animation: opac 6s infinite;
	}

	.countdown .circle {
		animation-delay: 1s;
	}

	.countdown .circle1 {
		animation-delay: 2s;
	}

	.countdown .circle2 {
		animation-delay: 3s;
	}

	.countdown .circle3 {
		animation-delay: 4s;
	}
>>>>>>> b0cc8c0 (hello)

	.callText {
		/* display: none; */
		width: 100%;
<<<<<<< HEAD
		height: 5vh;
		text-align: center;
		/* line-height: 2vh; */
		margin-top: 2vh;
=======
		height: 3vh;
		text-align: center;
		/* line-height: 2vh; */
		margin-top: 30vh;
>>>>>>> b0cc8c0 (hello)
		font-size: 42rpx;
		font-weight: bold;
	}

<<<<<<< HEAD
=======
	.msg {
		width: 100%;
		height: 50vh;
		margin-top: 5vh;
	}

>>>>>>> b0cc8c0 (hello)
	.callMsg {
		width: 100%;
		height: 8vh;
		/* background-color: #00FF7F; */
		margin-top: 2vh;
		display: flex;
		justify-content: center;

	}

	.callIcon {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
		/* background-color: #333333; */
		background-image: url(../../static/logo.png);
		overflow: hidden;
		background-size: cover;
		margin-right: 4vw;
	}

	.callName,
	.callPhone {
		font-size: 48rpx;
		margin: 1vh 0 0 2vw;
		/* margin: 0 auto; */
		/* text-align: center; */
	}
</style>
